package com.kaifamiao.dao.impl;

import com.kaifamiao.dao.IAccountDao;
import com.kaifamiao.model.Account;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;

import java.sql.SQLException;
import java.util.List;

/**
 * @author lucien-ma
 * @date 2021/8/24
 * @apiNote
 */
//@Repository("accountDao")
@Repository
public class IAccountDaoImpl implements IAccountDao {

    @Autowired
    private QueryRunner queryRunner;

    @Override
    public List<Account> findAll() {
        try {
            return queryRunner.query("select * from account", new BeanListHandler<>(Account.class));
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }
}
